/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest (seeAllData=true)
private class TestTransferWonLost {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        List<OpportunityLineItem> oppLineList = new List<OpportunityLineItem>();
    	Map<String, List<OpportunityLineItem>> maplist = new Map<String, List<OpportunityLineItem>>();
    	
        // TO DO: implement unit test
        Account accnt = new Account(Name='Cloud Concept');
        insert accnt;
        // load data
  		Opportunity oppOrig = new Opportunity();
		oppOrig.AccountId = accnt.id;
	 	oppOrig.MJB_Sales_Order__c = '12345';
		oppOrig.Initial_Interest__c = 'Human Resource';
	 	oppOrig.Opportunity_Description__c = 'Product Inquiry';
	 	oppOrig.Equipment__c = '';
	 	oppOrig.Customer_LPO__c = 'LPO Series';
	 	oppOrig.Model__c = '';
	 	oppOrig.CloseDate = date.today();
	 	oppOrig.Name = 'Q-100001 - Original';
		oppOrig.StageName = 'PO Awarded';
		insert oppOrig;	
		
		//reference orig        
        Opportunity opp = new Opportunity();
		opp.AccountId = accnt.id;
	 	opp.MJB_Sales_Order__c = '12345';
		opp.Initial_Interest__c = 'Human Resource';
	 	opp.Opportunity_Description__c = 'Product Inquiry';
	 	opp.Equipment__c = '';
	 	opp.Customer_LPO__c = 'LPO Series';
	 	opp.Model__c = '';
	 	opp.CloseDate = date.today();
	 	opp.Name = 'Q-100001';
		opp.StageName = 'PO Awarded';
		opp.Original_Opportunity_Name__c = 'Q-100001';
		insert opp;

      
		
		
	
        //create prod
        Product2 prod = new Product2(Name = 'Engine Product', isActive=True);
        insert prod;
        
        
        //fix to standard price not define
        //create prod
        Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book',isActive=True);
        insert pb;
        //query pricebook again
        Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];
        PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert standardPrice;

		//create won new line items		
		OpportunityLineItem wonOppLine = new OpportunityLineItem(
		OpportunityId=opp.id, 
 		PricebookEntryId=standardPrice.Id, 
 		Quantity=10, 
  		Discount=0, 
		UnitPrice=5, 
		Description='Bolts', 
		Part_Number__c='P123', 
		VAT_Value__c=0, 
		VAT_Code__c='0', 
		VAT_Rate__c=0, 
		Commission__c=0, 
		Freight_Rate__c=0, 
		Duty__c =0, 
		Margin__c=0, 
		UOM__c='NA', 
		Delivery_Days__c='10', 
		Inquiry_Part_No__c='PParts', 
		Product_Group__c='General', 
		Product_Group_Description__c='Tools', 
		Product_Group_Master__c='Master', 
		Item_Number__c=11,
		Line_Item_Status__c ='won',
		ServiceDate = date.today(),
		NL_Code__c = 'test', 
		NL_Code_Description__c = 'test'  
		 
		);
		oppLineList.add(wonOppline);
		
		OpportunityLineItem lostOppLine = new OpportunityLineItem(
		OpportunityId=opp.id, 
 		PricebookEntryId=standardPrice.Id, 
 		Quantity=10, 
  		Discount=0, 
		UnitPrice=5, 
		Description='Bolts', 
		Part_Number__c='P123', 
		VAT_Value__c=0, 
		VAT_Code__c='0', 
		VAT_Rate__c=0, 
		Commission__c=0, 
		Freight_Rate__c=0, 
		Duty__c =0, 
		Margin__c=0, 
		UOM__c='NA', 
		Delivery_Days__c='10', 
		Inquiry_Part_No__c='PParts', 
		Product_Group__c='General', 
		Product_Group_Description__c='Tools', 
		Product_Group_Master__c='Master', 
		Item_Number__c=11,
		Line_Item_Status__c ='lost',
		ServiceDate = date.today(),
		NL_Code__c = 'test', 
		NL_Code_Description__c = 'test'  
		 
		);		
		oppLineList.add(lostOppline);

		//insert the list
		insert oppLineList;
	        
        ApexPages.StandardController os = new ApexPages.Standardcontroller(opp);
		ext_TransferWonLost oppSplitPage = new ext_TransferWonLost(os);
		//call allmethods
		
		oppSplitPage.getDateValue();
		
		oppSplitPage.getOppLineItems();
		
		oppSplitPage.next();
    }
}